package com.yiqi.liebang.feature.home.view.adapter;

import android.view.View;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.suozhang.framework.framework.AM;
import com.yiqi.liebang.R;
import com.yiqi.liebang.common.widget.RatingBar;
import com.yiqi.liebang.entity.bo.QuestionBo;
import com.yiqi.liebang.entity.bo.QuestionDetailBo;

public class QuestionRecommendAdapter extends BaseQuickAdapter<QuestionDetailBo.QuestionBean,BaseViewHolder> {
    public QuestionRecommendAdapter() {
        super(R.layout.item_home_question);
    }

    @Override
    protected void convert(BaseViewHolder helper, QuestionDetailBo.QuestionBean item) {
        helper.setText(R.id.tv_user_question_content, item.getQuizcontent())
                .setText(R.id.tv_user_question_help, item.getAnswerUser()==null?"":"帮助过" + item.getAnswerUser().getHelpNum() + "人")
                .setText(R.id.tv_user_question_name, item.getAnswerUser()==null?"":item.getAnswerUser().getUserName() + "")
                .setText(R.id.tv_user_question_position, item.getAnswerUser()==null?"":item.getAnswerUser().getPosition())
                .setVisible(R.id.iv_user_position,item.getAnswerUser()==null?false:item.getAnswerUser().getIsOccupation()==1?true:false)
                .setText(R.id.tv_user_question_time, item.getChargestate() == 0 ? "限时免费" : "1元")

        ;
        if (item.getAnswerUser()==null?false:item.getAnswerUser().getIsBasic()==1){
            helper.getView(R.id.iv_user_certification).setVisibility(View.VISIBLE);
        }else {
            helper.getView(R.id.iv_user_certification).setVisibility(View.GONE);
        }
        RatingBar ratingBar = helper.getView(R.id.rb_user_question_star);
        ratingBar.setStar(item.getStartLevel());
        AM.image().bindToCircleObject(item.getAnswerUser()==null?"":item.getAnswerUser().getUserHead(),helper.getView(R.id.iv_user_question_head));
    }
}
